﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;

namespace GUI
{
    public partial class FormQuanLy : Form
    {
        //bien toan cuc:
        public int dangnhap;
        public string email ;
        public string matkhau ;
        public int manhanvien;
        public int makhachhang;
        public FormQuanLy()
        {
            InitializeComponent();
        }

        private void thanhToanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form frm = GUI.KiemTraTonTai(typeof(FormThanhToan), this);
            if (frm != null)
            {
                FormThanhToan f = (FormThanhToan)frm;
                f.Activate();
            }
            else
            {
                FormThanhToan f = new FormThanhToan();
                f.MdiParent = this;
                f.Show();
            }
        }

        private void donHangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form frm = GUI.KiemTraTonTai(typeof(FormDonHang), this);
            if (frm != null)
            {
                FormDonHang f = (FormDonHang)frm;
                f.manhanvien = manhanvien;
                f.matkhau = matkhau;
                f.email = email;
                f.makhachhang = makhachhang;
                f.dangnhap = dangnhap;
                f.Activate();
            }
            else
            {
                FormDonHang f = new FormDonHang();
                f.MdiParent = this;
                f.manhanvien = manhanvien;
                f.matkhau = matkhau;
                f.email = email;
                f.makhachhang = makhachhang;
                f.dangnhap = dangnhap;
                f.Show();
            }
        }

        private void khachHangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dangnhap == 1)//nhan vien
            {
                Form frm = GUI.KiemTraTonTai(typeof(FormKhachHang), this);
                if (frm != null)
                {
                    FormKhachHang f = (FormKhachHang)frm;
                    f.dangnhap = dangnhap;
                    f.Activate();
                }
                else
                {
                    FormKhachHang f = new FormKhachHang();
                    f.MdiParent = this;
                    f.dangnhap = dangnhap;
                    f.Show();
                }
            }
            else if (dangnhap == 2)//khach hang
            {
                Form frm = GUI.KiemTraTonTai(typeof(FormChiTietKhachHang), this);
                if (frm != null)
                {
                    FormChiTietKhachHang f = (FormChiTietKhachHang)frm;
                    f.maKhachHang = makhachhang;
                    f.Activate();
                }
                else
                {
                    FormChiTietKhachHang f = new FormChiTietKhachHang();
                    f.MdiParent = this;
                    f.maKhachHang = makhachhang;
                    f.Show();
                }
            }
           
        }

        private void sanPhamToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form frm = GUI.KiemTraTonTai(typeof(FormSanPham), this);
            if (frm != null)
            {
                FormSanPham f = (FormSanPham)frm;
                f.Activate();
            }
            else
            {
                FormSanPham f = new FormSanPham();
                f.MdiParent = this;
                f.Show();
            }
        }

        private void FormQuanLy_Load(object sender, EventArgs e)
        {
            if (dangnhap == 2)
            {
                sanPhamToolStripMenuItem.Visible = false;
            }
            else
            {
                thanhToanToolStripMenuItem.Visible = false;
            }
        }
    }
}
